<template>
  <div id="main">
    <!-- 头部 -->
    <div class="record">
     <div class="header">
           <van-nav-bar title="乐呗采购管理系统" />
       </div>
      <div class="onEvt">
        <ul>
          <li>昨日</li>
          <li>今日</li>
          <li>本月</li>
        </ul>
      </div>
      <div class="price">7</div>
      <span>完成量（笔）</span>
    </div>
    <van-row type="flex" justify="space-between">
      <van-col span="12">
        采购数量（笔）
        <br />
        <span>12</span>
        <i>
          <van-icon name="fire-o" color="#ee0a24" />
        </i>
      </van-col>
      <van-col span="12">
        收款金额（元）
        <br />
        <span>2460</span>
        <i>
          <van-icon name="fire-o" color="#ee0a24" />
        </i>
      </van-col>
    </van-row>
    <!-- 轮播 -->
    <div class="main">
      <div class="swiper">
        <h3>订单状态</h3>
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
          <van-swipe-item>订单在途中...(2笔)</van-swipe-item>
          <van-swipe-item>订单待确认...(2笔)</van-swipe-item>
          <van-swipe-item>订单待收款...(1笔)</van-swipe-item>
          <van-swipe-item>订单待审批...(3笔)</van-swipe-item>
        </van-swipe>
      </div>
      <!-- 公告 -->
      <div class="wel">
        <van-notice-bar scrollable left-icon="volume-o" text="欢迎使用乐呗采购后台管理系统。" />
      </div>
      <!-- 菜单 -->
      <div v-for="(items,index) in funcList" :key="index" class="menu">
        <h3>{{items.title}}</h3>
        <van-grid :column-num="4" gutter="8px">
          <van-grid-item v-for="(it,i) in items.items" :key="i" :text="it.name" @click="toPage(it)">
            <template #icon>
              <i  v-html="it.icon"></i>
            </template>
          </van-grid-item>
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  props: ["funcList"],
  data() {
    return {
      property: "&#xe609;"
    };
  },
  methods:{
    /**
     * 菜单鉴权
     * @param {*} item 
     */
    toPage(item){
       if(!item.right) return this.$router.push(item.path)
       let right = this.userRole.find( it => item.id === it.id ) 
       if(!right){
        this.$toast({
          message:'您没有该菜单的任何权限',
        })
        return
       }
      if(!right.role.includes(item.right)){
        this.$toast({
          message:'您没有该权限',
        })
        return
      }
      this.$router.push(item.path)
    }
  },
  computed:{
    ...mapState('common',['userRole'])
  }
};
</script>

<style lang="less" scoped>
@import "@/style/index.less";
.van-hairline--bottom{
  background-color:#6199ff;
}
//头部
.header/deep/  .van-nav-bar__title {
  color: #F2F2F2 !important;
  font-size: 20px;
}
#main {
  display: block;
  h3 {
    &::before {
      content: "";
      display: inline-block;
      vertical-align: sub;
      height: 22px;
      width: 3px;
      background-color: @c1;
      margin-right: 12px;
    }
  }

  //蓝色板块
  > .record {
    height: 210px;
    display: block;
    background-color: @c1;
    > header {
      display: block;
      height: 42px;
      line-height: 42px;
      font-size: @20;
      text-align: center;
      font-weight: 600;
      color: @c10;
    }
    > .onEvt {
      height: 42px;
      line-height: 42px;
      text-align: center;
      color: @c10;
      font-size: @18;
      font-weight: 600;
      > ul {
        padding: 0;
        margin: auto;
        display: flex;
        justify-content: space-evenly;
        li:hover {
          border-bottom: 3px solid @c10;
        }
      }
      ul li {
        list-style: none;
      }
    }
    > .price {
      display: block;
      margin-top: 12px;
      height: 38px;
      line-height: 38px;
      text-align: center;
      color: @c10;
      font-size: @20;
      font-weight: 600;
      margin-bottom: 8px;
    }
    > span {
      display: block;
      font-size: @14;
      text-align: center;
      color: @c10;
    }
  }
  > .van-row {
    margin: 12px;
    height: 80px;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 0 6px;
    line-height: 46px;
    > .van-col {
      font-size: @14;
      font-weight: 300;
      > span {
        font-weight: 600;
        display: inline-block;
        font-size: @20;
      }
    }
    i {
      display: block;
      width: 32px;
      height: 32px;
      line-height: 32px;
      // background-color: gray;
      text-align: center;
      // border: 1px solid green;
      float: right;
    }
    
  }
  //轮播
  .main {
    > .swiper {
    margin: 14px 6px 14px 6px;
    .van-swipe {
      line-height: 80px;
      height: 80px;
      text-align: center;
      color: @c10;
      font-size: @16;
      background-image: linear-gradient(@c1,@c3);
    }
  }
  }
  
  
  > .wel {
    margin: 14px 6px 14px 6px;
  }
  // 项目管理
  .menu {
    margin-top: 14px;
    i {
      display: block;
      width: 48px;
      height: 48px;
      margin: auto;
      text-align: center;
      line-height: 36px;
      .lebei-ft(1.8rem,@c3);
    }
    > span {
      display: block;
      text-align: center;
      font-size: @14;
      line-height: 20px;
      color: @c7;
    }
  }
  
}

</style>